package cn.fscode.code.generator.common.config;

import cn.fscode.code.generator.common.GenConstants;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;

/**
 * 解决vue项目打包后, 放在spring-boot后端, 整合一起打包. 访问页面后, 刷新出现404的情况
 * @author shenguangyang
 */
@Component
public class ErrorConfig implements ErrorPageRegistrar {
    @Override
    public void registerErrorPages(ErrorPageRegistry registry) {
        ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, GenConstants.FORWARD_INDEX);
        registry.addErrorPages(error404Page);
    }
}
